import httpRequest from "@/utils/http-request.js";

/**
 * 列出所有
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const all = () => {
    return httpRequest.get("/v1/sys/dept/all");
}

/**
 * 树结构查询
 * @returns {*}
 */
export const tree = () => {
    return httpRequest.get("/v1/sys/dept/tree");
}

/**
 * 新增
 * @param dataScope
 * @param name
 * @param permission
 * @param sort
 * @param deptIds
 * @param menuIds
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const add = ({parentId, name}) => {
    return httpRequest.post("/v1/sys/dept", {
        parentId, name
    });
}

/**
 * 根据ID修改
 * @param id
 * @param dataScope
 * @param name
 * @param permission
 * @param sort
 * @param deptIds
 * @param menuIds
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const modifyById = (id, {parentId, name, deptNo}) => {
    return httpRequest.put(`/v1/sys/dept/${id}`, {
        parentId, name, deptNo
    });
}

/**
 * 详情
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const detailById = (id) => {
    return httpRequest.get(`/v1/sys/dept/detail/${id}`);
}

/**
 * 根据ID删除
 * @param id
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteById = (id) => {
    return httpRequest.delete(`/v1/sys/dept/${id}`);
}